with open('f.txt', 'r', encoding='utf-8') as f:
    content = f.read()
    print(content)
# 使用with语句写入文件
with open('f.txt', 'w', encoding='utf-8') as f:
    f.write('Hello, world!!')